﻿/*
Plugin=CustomPlugin_GoogleTranslate
Name1=谷歌智能翻译 中文转英文 英文转中文
Command1=CustomPlugin_GoogleTranslate
Version=1.0
*/
CustomPlugin_GoogleTranslate(){

	ExplorerPath := QZData("text")
	if (RegExMatch(ExplorerPath,"[^\x00-\xff]+"))
	{
		GoogleTranslate := GoogleTranslate(ExplorerPath,from := "auto", to :=0409)
		Gui Gui_Google_danci: Font,s14 微软雅黑 c62384C q2
		Gui Gui_Google_danci:add,Edit,x10 y10 w300 h100,%GoogleTranslate%
		Gui Gui_Google_danci:show,,谷歌翻译
		return

	}
		; ; 判断如果是英文就翻译成中文
	if (RegExMatch(ExplorerPath,"^[A-Za-z]+"))
	{
		GoogleTranslate := GoogleTranslate(ExplorerPath)
		Gui Gui_Google_danci: Font,s14 微软雅黑 c62384C q2
		Gui Gui_Google_danci:add,Edit,x10 y10  w300 h100,%GoogleTranslate%
		Gui Gui_Google_danci:show,,谷歌翻译
		return

	}
		Gui_Google_danciGuiClose:
		Gui_Google_danciGuiEscape:
		Gui Gui_Google_danci:destroy
		clipboard := ""
		return
	; }
}

CustomPlugin_QTranslate(){
	ExplorerPath := QZData("text")
	clipboard := ExplorerPath
	Process, Wait, QTranslate.exe, 1
	NewPID := ErrorLevel  ; 由于 ErrorLevel 会经常发生改变, 所以要立即保存这个值.
	if not NewPID
	{
		run,%A_ScriptDir%\Apps\QTranslate\QTranslate.exe
		Sleep,500
		Send, ^+{t}
		return
	}
	if NewPID
	{
		Send, ^+{t}
		return
		}
	return
}
